import React, {createContext, useState} from 'react'
import UseChild from './UseChild'

export const MyContext = createContext();

export default function UseContext() {
  // useContext要解决的问题是，组件之间跨级传递数据不方便
  const [name, setName] = useState('Tom')
  return (
    <div>
      <p>父组件</p>
      <MyContext.Provider value={name}>
        <UseChild></UseChild>
      </MyContext.Provider>
    </div>
  )
}
